/**
 *  Copyright (c) 2011, IPC Studio, USTC, All rights reserved
 *  FileName: TxtEncoder.h
 *  Author: LewGate@gmail.com
 *  DateCreated: 2011-8-8
 *  Brief: class TxtEncoder definition, used to deal with text encoding
 */

#ifndef TXTENCODER_H_
#define TXTENCODER_H_

#include "../include/common.h"
#include <windows.h>
#include <cctype>
#include <algorithm>
LIBLYRICS_NAMESPACE_BEGIN

class TxtEncoder
{
public:
	TxtEncoder();
	virtual ~TxtEncoder();

	bool			SetBuffer(char* pbuffer, int size);
	char*			Convert(int sourceCodepage, int targetCodepage);
	bool			IsUTF8NOBOM(long size);
	bool			IsUTF16NOBOM(long bytesize);
	CODINGTYPE		GetCodingType(long bytesize);
	void            ReadFileIntoRam(FILE* plrcfile, string& alllrc);
	static string	wstring2string(wstring ws);
	static void		BigEndiaToLittleEndia(TCHAR * pBuffer, long size);

protected:
	char*			m_pbuffer;
};

LIBLYRICS_NAMESPACE_END
#endif